#include "GameMenu.h"

GameMenu::GameMenu() {
}


GameMenu::~GameMenu() {
}


void GameMenu::Initialize(sf::RenderWindow* window) {
	m_renderWindow = window;

	MenuTexture.loadFromFile("bilder/Menu/menu_screen.png");
	MenuSprite.setTexture(MenuTexture);

	PlayTexture.loadFromFile("bilder/Menu/play.png");
	PlaySprite.setTexture(PlayTexture);
	PlaySprite.setOrigin(PlayTexture.getSize().x/4, PlayTexture.getSize().y/2);
	PlaySprite.setPosition(MenuTexture.getSize().x/2, 310);

	QuitTexture.loadFromFile("bilder/Menu/Quit.png");
	QuitSprite.setTexture(QuitTexture);
	//QuitSprite.setOrigin(QuitTexture.getSize().x/4, QuitTexture.getSize().y/2);
	QuitSprite.setPosition(1090, 640);

	/*
	HelpTexture.loadFromFile("bilder/Menu/how_to_play.png");
	HelpSprite.setTexture(HelpTexture);
	HelpSprite.setOrigin(HelpTexture.getSize().x/4, HelpTexture.getSize().y/2);
	HelpSprite.setPosition(MenuTexture.getSize().x/2, 400);
	*/

	OptionsTexture.loadFromFile("bilder/Menu/Options.png");
	OptionsSprite.setTexture(OptionsTexture);
	OptionsSprite.setOrigin(OptionsTexture.getSize().x/4, OptionsTexture.getSize().y/2);
	OptionsSprite.setPosition(MenuTexture.getSize().x/2, 400);


	ScoreboardTexture.loadFromFile("bilder/Menu/High_score.png");
	ScoreboardSprite.setTexture(ScoreboardTexture);
	ScoreboardSprite.setOrigin(ScoreboardTexture.getSize().x/4, ScoreboardTexture.getSize().y/2);
	ScoreboardSprite.setPosition(MenuTexture.getSize().x/2, 488);


	CreditsTexture.loadFromFile("bilder/Menu/Credits.png");
	CreditsSprite.setTexture(CreditsTexture);
	CreditsSprite.setOrigin(CreditsTexture.getSize().x/4, CreditsTexture.getSize().y/2);
	CreditsSprite.setPosition(MenuTexture.getSize().x/2, 578);


}

void GameMenu::Update(sf::Vector2i mousePos) {
	m_mousePos = mousePos;

	m_renderWindow->draw(MenuSprite);

	// If in quit
	if (m_mousePos.x > 1028 && m_mousePos.x < 1263 && m_mousePos.y < 702 && m_mousePos.y > 631) {
		QuitSprite.setTextureRect(sf::IntRect(134,0,136,58));
	} else {
		QuitSprite.setTextureRect(sf::IntRect(0,0,134,58));
	}


	m_renderWindow->draw(QuitSprite);

	// If in play
	if (m_mousePos.x > 454 && m_mousePos.x < 817 && m_mousePos.y < 347 && m_mousePos.y > 272) {
		PlaySprite.setTextureRect(sf::IntRect(108,0,108,44));
	} else {
		PlaySprite.setTextureRect(sf::IntRect(0,0,108,44));
	}



	m_renderWindow->draw(PlaySprite);


	
	// If in help
	if (m_mousePos.x > 454 && m_mousePos.x < 817 && m_mousePos.y < 437 && m_mousePos.y > 360) {
		//HelpSprite.setTextureRect(sf::IntRect(281,0,281,57));
		OptionsSprite.setTextureRect(sf::IntRect(198,0,198,54));
	} else {
		//HelpSprite.setTextureRect(sf::IntRect(0,0,281,57));
		OptionsSprite.setTextureRect(sf::IntRect(0,0,198,54));
	}

	//m_renderWindow->draw(HelpSprite);
	


	// If in options
	if (m_mousePos.x > 454 && m_mousePos.x < 817 && m_mousePos.y < 525 && m_mousePos.y > 447) {
		//OptionsSprite.setTextureRect(sf::IntRect(198,0,198,54));
		ScoreboardSprite.setTextureRect(sf::IntRect(268,0,268,66));
	} else {
		//OptionsSprite.setTextureRect(sf::IntRect(0,0,198,54));
		ScoreboardSprite.setTextureRect(sf::IntRect(0,0,268,66));
	}

	m_renderWindow->draw(OptionsSprite);

	// If in scoreboard
	if (m_mousePos.x > 454 && m_mousePos.x < 817 && m_mousePos.y < 612 && m_mousePos.y > 537) {
		//ScoreboardSprite.setTextureRect(sf::IntRect(268,0,268,66));
		CreditsSprite.setTextureRect(sf::IntRect(190,0,190,48));
	} else {
		//ScoreboardSprite.setTextureRect(sf::IntRect(0,0,268,66));
		CreditsSprite.setTextureRect(sf::IntRect(0,0,190,48));
	}

	m_renderWindow->draw(ScoreboardSprite);
	/*
	// If in credits
	if (m_mousePos.x > 454 && m_mousePos.x < 817 && m_mousePos.y < 699 && m_mousePos.y > 624) {
		//CreditsSprite.setTextureRect(sf::IntRect(190,0,190,48));
	} else {
		//CreditsSprite.setTextureRect(sf::IntRect(0,0,190,48));
	}
	*/
	m_renderWindow->draw(CreditsSprite);

}

void GameMenu::Cleanup() {

}